/*=+--+=#=+--     Unmanned Aerial System Management Software      --+=#=+--+=#*\
|          Copyright (C) 2011 Regents of the University of Colorado.           |
|                             All Rights Reserved.                             |

     This program is free software: you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as
     published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.

            Jack Elston                       Cory Dixon                        
|           elstonj@colorado.edu              dixonc@colorado.edu              |
|                                                                              |
\*=+--+=#=+--                 --+=#=+--+=#=+--                    --+=#=+--+=#*/

/***********************************************************************
 *
 * FILENAME:
 * gtk_gpsmap.c
 *
 * PURPOSE:
 *	Provide a GPS map interface to the user.
 *
 * LAST MODIFIED:
 *
 ***********************************************************************/

#include "geoVideo.h"
#include "utilities.h"

#include <iomanip>
using namespace std;

GeoVideo::GeoVideo(void)
{
	pixbuf = NULL;

	width = height = 0;
	img_tieX = img_tieY = m_tieX = m_tieY = m_resX = m_resY = 0.0;
}

GeoVideo::~GeoVideo(void)
{
	if(pixbuf) gdk_pixbuf_unref(pixbuf); 
	pixbuf = NULL;
}


void GeoVideo::setPixbuf(GdkPixbuf *img)
{
	pixbuf = img;
	width = gdk_pixbuf_get_width(pixbuf);
	height = gdk_pixbuf_get_height(pixbuf);
}

bool GeoVideo::geoToImage(double &x, double &y)
{
	x = (x - m_tieX) / m_resX + img_tieX;	
	y = (y - m_tieY) / m_resY + img_tieY;	

	return true;
}

void GeoVideo::setDegPerP(double x, double y) 
{
	m_resX = x;
	m_resY = y;
}

void GeoVideo::setTiePoints(double x, double y) 
{ 	
	m_tieX = x;
	m_tieY = y;

	return;
}

void GeoVideo::getTiePoints(double &x, double &y) 
{ 	
	x = m_tieX - img_tieX * m_resX; 
	y = m_tieY - img_tieY * m_resY; 

	return;
}

bool GeoVideo::imageToGeo(double &x, double &y)
{
	x = (x - img_tieX) * m_resX + m_tieX;
	y = (y - img_tieY) * m_resY + m_tieY;

	return true;
}




